import React, {Component} from 'react';
import {
  Dimensions,
  Image,
  StyleSheet,
  Text,
  View,
  ScrollView,
  TouchableOpacity,
  ActivityIndicator,
  ImageBackground,
  TextInput,
  Button,
} from 'react-native';

import {CommonImg, ProposalImg} from '../../images/index';
TextInput.defaultProps = Object.assign({}, TextInput.defaultProps, {
  defaultProps: false,
});
Text.defaultProps = Object.assign({}, Text.defaultProps, {
  allowFontScaling: false,
});
// const {height, width} = Dimensions.get('window');
let height = Dimensions.get('window').height;
let width = Dimensions.get('window').width;
let prama = '0';
// import TabBar from '../TabBar';
// import History from '../History';
import ProposalList from '../ProposalList';
import {getDirector} from '../../api/Proposal/index';

export default class HGBCSheQuZhiLi extends React.Component {
  constructor(props) {
    super();
    this.state = {
      selectedTab: 'goverment',
    };
  }
  //TODO 判断用户是否有权限进入提案界面
  async fetchJurisdiction() {
    try {
      const role = await getDirector();
      this.setState({
        Jurisdiction: role.error_code,
      });
    } catch (e) {
      //this.props.setToastMsg('');
    }

    //alert(this.state.Jurisdiction);
  }
  componentDidMount() {
    this.fetchJurisdiction();
  }
  render() {
    return (
      <View>
        <ScrollView style={{height: height * 0.8845}}>
          <View style={{backgroundColor: '#F3F7FA'}}>
            <View style={styles.Instruction}>
              <View
                style={{
                  flexDirection: 'row',
                  width: 375,
                  height: height * 0.0749,
                }}>
                <View style={styles.boder1} />
                <Text style={styles.InsTitle}>了解DNA社区</Text>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('AboutCommunity');
                  }}>
                  <Image style={styles.iconstyle} source={CommonImg.Arrow} />
                </TouchableOpacity>
              </View>
              <View
                style={{
                  flexDirection: 'column',
                  height: height * 0.3223,
                  width: width,
                }}>
                <ImageBackground
                  style={styles.boder2}
                  source={ProposalImg.Border}
                  resizeMode={'stretch'}>
                  <Text style={styles.InsText}>
                    亲爱的个人/机构用户：本项目是秉持中本聪先生去中心化思想初心而设立的DAO（去中心化自治组织），组织架构基于非盈利基金会，不是传统的公司制也不为任何私有利益服务。围绕本项目产生的一切权益属于全体token持有者。公正、公开、公信是我们的共同理想，快快参与进来吧！
                  </Text>
                </ImageBackground>
              </View>
            </View>
            <View style={styles.List}>
              <View
                style={{
                  flexDirection: 'row',
                  width: width,
                  height: height * 0.0749,
                }}>
                <View style={styles.boder1} />
                <Text style={styles.InsTitle}>治理进行时</Text>
              </View>
              <View
                style={{
                  width: width,
                  height: height * 0.0704,
                  marginTop: height * 0.0224,
                  flexDirection: 'row',
                }}>
                <TouchableOpacity
                  onPress={() => {
                    if (this.state.Jurisdiction === 0) {
                      this.props.navigation.navigate('Second');
                    } else {
                      alert('对不起，您无权发起提案');
                    }
                  }}>
                  <View style={{flexDirection: 'row'}}>
                    <View
                      style={{
                        marginLeft: width * 0.08,
                        width: height * 0.0704,
                        height: height * 0.0704,
                        borderWidth: 5,
                        borderColor: '#33CCCC',
                        borderRadius: 1,
                        backgroundColor: '#33CCCC',
                        justifyContent: 'center',
                        alignItems: 'center',
                      }}>
                      <Text
                        style={{
                          //fontFamily: 'MicrosoftYaHei',
                          fontSize: 13,
                          textAlign: 'center',
                          color: '#FFFFFF',
                        }}>
                        提案
                      </Text>
                    </View>
                    <View
                      style={{
                        width: width * 0.64,
                        height: height * 0.0704,
                        flexDirection: 'column',
                      }}>
                      <Text style={styles.ListText1}>
                        点击这里提出你的提案吧！
                      </Text>
                      <Text style={styles.ListText2}>你或将带来变革。</Text>
                    </View>
                  </View>
                </TouchableOpacity>
                <TouchableOpacity
                  onPress={() => {
                    if (this.state.Jurisdiction === 0) {
                      this.props.navigation.navigate('Second');
                    } else {
                      alert('对不起，您无权发起提案');
                    }
                  }}>
                  <Image
                    style={{
                      marginLeft: width * 0.06,
                      marginTop: height * 0.0269,
                      width: width * 0.0213,
                      height: height * 0.0209,
                    }}
                    source={CommonImg.Arrow}
                  />
                </TouchableOpacity>
              </View>
              <View
                style={{
                  marginLeft: width * 0.08,
                  marginTop: height * 0.0299,
                  height: (height * 7.496) / 10000,
                  width: width * 0.84,
                  borderBottomWidth: (height * 7.496) / 10000,
                  borderColor: '#E5E5E5',
                }}
              />
              <View
                style={{
                  width: width,
                  height: height * 0.0704,
                  marginTop: height * 0.0299,
                  flexDirection: 'row',
                }}>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 1});
                  }}>
                  <View style={{flexDirection: 'row'}}>
                    <View
                      style={{
                        marginLeft: 0.08 * width,
                        width: height * 0.0704,
                        height: height * 0.0704,
                        borderWidth: 5,
                        borderColor: '#FF7067',
                        borderRadius: 1,
                        backgroundColor: '#FF7067',
                        justifyContent: 'center',
                        alignItems: 'center',
                      }}>
                      <Text
                        style={{
                          //fontFamily: 'MicrosoftYaHei',
                          fontSize: 13,
                          textAlign: 'center',
                          color: '#FFFFFF',
                        }}>
                        联名
                      </Text>
                    </View>
                    <View
                      style={{
                        width: width * 0.64,
                        height: height * 0.0704,
                        flexDirection: 'column',
                      }}>
                      <Text style={styles.ListText1}>
                        董事们的提案正在征求联名！
                      </Text>
                      <Text style={styles.ListText2}>附议你认同的提案！</Text>
                    </View>
                  </View>
                </TouchableOpacity>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 1});
                  }}>
                  <Image
                    style={{
                      marginLeft: width * 0.06,
                      marginTop: height * 0.0269,
                      width: width * 0.0213,
                      height: height * 0.0209,
                    }}
                    source={CommonImg.Arrow}
                  />
                </TouchableOpacity>
              </View>
              <View
                style={{
                  marginLeft: width * 0.08,
                  marginTop: height * 0.0299,
                  height: (height * 7.496) / 10000,
                  width: width * 0.84,
                  borderBottomWidth: (height * 7.496) / 10000,
                  borderColor: '#E5E5E5',
                }}
              />
              <View
                style={{
                  width: width,
                  height: height * 0.0704,
                  marginTop: height * 0.0299,
                  flexDirection: 'row',
                }}>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 2});
                  }}>
                  <View style={{flexDirection: 'row'}}>
                    <View
                      style={{
                        marginLeft: width * 0.08,
                        width: height * 0.0704,
                        height: height * 0.0704,
                        borderWidth: 5,
                        borderColor: '#FFA34B',
                        borderRadius: 1,
                        backgroundColor: '#FFA34B',
                        justifyContent: 'center',
                        alignItems: 'center',
                      }}>
                      <Text
                        style={{
                          //fontFamily: 'MicrosoftYaHei',
                          fontSize: 13,
                          textAlign: 'center',
                          color: '#FFFFFF',
                        }}>
                        表决
                      </Text>
                    </View>
                    <View
                      style={{
                        width: width * 0.64,
                        height: height * 0.0704,
                        flexDirection: 'column',
                      }}>
                      <Text style={styles.ListText1}>全民参与，投票表决！</Text>
                      <Text style={styles.ListText2}>
                        你也有权决定提案是否执行。
                      </Text>
                    </View>
                  </View>
                </TouchableOpacity>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 2});
                  }}>
                  <Image
                    style={{
                      marginLeft: width * 0.06,
                      marginTop: height * 0.0269,
                      width: width * 0.0213,
                      height: height * 0.0209,
                    }}
                    source={CommonImg.Arrow}
                  />
                </TouchableOpacity>
              </View>
              <View
                style={{
                  marginLeft: width * 0.08,
                  marginTop: height * 0.0299,
                  height: (height * 7.496) / 10000,
                  width: width * 0.84,
                  borderBottomWidth: (height * 7.496) / 10000,
                  borderColor: '#E5E5E5',
                }}
              />
              <View
                style={{
                  width: width,
                  height: height * 0.0704,
                  marginTop: height * 0.0299,
                  flexDirection: 'row',
                }}>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 3});
                  }}>
                  <View style={{flexDirection: 'row'}}>
                    <View
                      style={{
                        marginLeft: width * 0.08,
                        width: height * 0.0704,
                        height: height * 0.0704,
                        borderWidth: 5,
                        borderColor: '#8587FF',
                        borderRadius: 1,
                        backgroundColor: '#8587FF',
                        justifyContent: 'center',
                        alignItems: 'center',
                      }}>
                      <Text
                        style={{
                          //fontFamily: 'MicrosoftYaHei',
                          fontSize: 13,
                          textAlign: 'center',
                          color: '#FFFFFF',
                        }}>
                        执行
                      </Text>
                    </View>
                    <View
                      style={{
                        width: width * 0.64,
                        height: height * 0.0704,
                        flexDirection: 'column',
                      }}>
                      <Text style={styles.ListText1}>提案执行的如何了？</Text>
                      <Text style={styles.ListText2}>
                        查看董事们的执行报告。
                      </Text>
                    </View>
                  </View>
                </TouchableOpacity>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 3});
                  }}>
                  <Image
                    style={{
                      marginLeft: width * 0.06,
                      marginTop: height * 0.0269,
                      width: width * 0.0213,
                      height: height * 0.0209,
                    }}
                    source={CommonImg.Arrow}
                  />
                </TouchableOpacity>
              </View>
              <View
                style={{
                  marginLeft: width * 0.08,
                  marginTop: height * 0.0299,
                  height: (height * 7.496) / 10000,
                  width: width * 0.84,
                  borderBottomWidth: (height * 7.496) / 10000,
                  borderColor: '#E5E5E5',
                }}
              />
              <View
                style={{
                  width: width,
                  height: height * 0.0704,
                  marginTop: height * 0.0299,
                  flexDirection: 'row',
                }}>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 4});
                  }}>
                  <View style={{flexDirection: 'row'}}>
                    <View
                      style={{
                        marginLeft: width * 0.08,
                        width: height * 0.0704,
                        height: height * 0.0704,
                        borderWidth: 5,
                        borderColor: '#45BAFF',
                        borderRadius: 1,
                        backgroundColor: '#45BAFF',
                        justifyContent: 'center',
                        alignItems: 'center',
                      }}>
                      <Text
                        style={{
                          //fontFamily: 'MicrosoftYaHei',
                          fontSize: 13,
                          textAlign: 'center',
                          color: '#FFFFFF',
                        }}>
                        验收
                      </Text>
                    </View>
                    <View
                      style={{
                        width: width * 0.64,
                        height: height * 0.0704,
                        flexDirection: 'column',
                      }}>
                      <Text style={styles.ListText1}>满意提案的收效吗？</Text>
                      <Text style={styles.ListText2}>
                        满意的话，就为它点个赞。
                      </Text>
                    </View>
                  </View>
                </TouchableOpacity>
                <TouchableOpacity
                  onPress={() => {
                    this.props.navigation.navigate('ProposalList', {stage: 4});
                  }}>
                  <Image
                    style={{
                      marginLeft: width * 0.06,
                      marginTop: height * 0.0269,
                      width: width * 0.0213,
                      height: height * 0.0209,
                    }}
                    source={CommonImg.Arrow}
                  />
                </TouchableOpacity>
              </View>
            </View>
          </View>
          <View style={{backgroundColor: '#F3F7FA', height: height * 0.2}} />
        </ScrollView>
      </View>
    );
  }
}
let styles = StyleSheet.create({
  Instruction: {
    marginTop: height * 0.0224,
    height: height * 0.4572,
    width: 375,
    backgroundColor: '#FFFFFF',
  },
  boder1: {
    marginLeft: width * 0.0533,
    marginTop: height * 0.0179,
    height: height * 0.0254,
    width: width * 0.0133,
    borderBottomWidth: 0.0194 * height,
    borderColor: '#2672C0',
    backgroundColor: '#2672C0',
  },
  InsTitle: {
    marginLeft: width * 0.0186,
    marginTop: height * 0.0179,
    //fontFamily: 'MicrosoftYaHei',
    fontSize: 15,
    textAlign: 'left',
    color: '#333333',
    fontWeight: 'bold',
  },
  iconstyle: {
    marginLeft: 375 * 0.6,
    marginTop: height * 0.0269,
    width: width * 0.0213,
    height: height * 0.0209,
    resizeMode: 'stretch',
  },
  boder2: {
    marginLeft: 375 * 0.0533,
    width: 375 * 0.8933,
    height: height * 0.2788,
    marginTop: height * 0.0149,
    resizeMode: 'stretch',
  },
  InsText: {
    marginLeft: width * 0.0453,
    marginTop: height * 0.0194,
    width: 375 * 0.8026,
    color: '#181818',
    textAlign: 'left',
    fontSize: 12,
    //fontFamily: 'MicrosoftYaHei',
    lineHeight: 27,
  },
  List: {
    marginTop: height * 0.0224,
    height: height * 0.7391,
    width: 375,
    backgroundColor: '#FFFFFF',
  },
  ListText1: {
    marginTop: height * 0.0059,
    marginLeft: width * 0.04,
    fontSize: 12,
    //fontFamily: 'MicrosoftYaHei',
    color: '#333333',
    textAlign: 'left',
  },
  ListText2: {
    marginLeft: width * 0.04,
    marginTop: height * 0.0074,
    fontSize: 11,
    //fontFamily: 'MicrosoftYaHei',
    color: '#989898',
    textAlign: 'left',
  },
});
